package com.zack.util.multitype.file;

import java.io.InputStream;
import java.nio.file.Path;
import java.nio.file.Paths;

/**
 * 2016 11-10 email: hanzack@163.com author: zack
 **/
public class ClassPathResource {

    private String path;

    public ClassPathResource(String path) {
        this.path = path;
    }

    public String getPath() {
        return path;
    }

    public String getAbsolutePath() {
        return getClass().getClassLoader().getResource(path).getFile();
    }

    public InputStream getInputStream() {
        InputStream is = getClass().getClassLoader().getResourceAsStream(path);
        return is;
    }

    public String getFilename() {
        Path pathname = Paths.get(path);
        return pathname.getFileName().toString();
    }
}
